<template>
	<view class="xb-page">
		<form @submit="submitform">
			<view class="xb-page-container">
				<view class="xb-section-title">基本信息</view>
				<view class="xb-form-cell">
					<view class="xb-form-cell-row">
						<input v-model="formdata.empname" class="xb-input" placeholder="老师姓名" />
					</view>
				</view>
				<view class="xb-form-cell">
					<view class="xb-form-cell-row">
						<input v-model="formdata.tel" class="xb-input" placeholder="联系方式" />
					</view>
				</view>
				<view class='xb-section-title' style="margin-top: 10px;">权限设置</view>
				<view>
					<uniTag  @click="()=>item.select=!item.select" v-for="(item,index) in rolesList" size="default" type="primary" :circle="item.select==true? true:false " :key="index" :text="item.name">
					</uniTag>
				</view>
				<view class="xb-button-cell">
					<button form-type="submit" class="xb-button page-button" size="mini" plain="true" type="primary">完成</button>
				</view>
			</view>
		</form>
	</view>
</template>

<script>
	import pageHead from '../../../components/page-head.vue';
	import uniTag from '../../../components/uni-tag.vue';
	export default {
		components: {
			pageHead,
			uniTag,
		},

		data() {
			return {
				rolesList: [{
					'name': '学员',
					'select':true,
				}, {
					'name': '请假调课',
					'select':true,
					''
				}, {
					'name': '财务',
					'select':true,
				}],
				formdata: {
					empname: '',
					tel: '',
				},
			}

		},
		methods: {
			submitform: async function() {
				this.rolesList.filter(item => {
					return item.select == true;
				})
				formdata.roleslist = this.rolesList;
				const res = await addEmp(formdata);
				if (res.success == true) {
					uni.navigateBack({
						delta: 1,
					})

				} else {

				}

			},



		}
	}
</script>

<style scoped>
	@import "../../../common/uni.css";
	@import "../../../common/xb.css";
	.page-button {
		position: absolute;
		left: 0%;
		width: 100%;
	}
</style>
